package com.example.animalcase;

import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.MediaController;
import android.widget.VideoView;

public class Mp4Activity extends AppCompatActivity {

    private VideoView mVideoView;
    MediaController mMediaController;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mp4);

        mVideoView = new VideoView(this);
        mVideoView = (VideoView) findViewById(R.id.videoView);
        mMediaController = new MediaController(this);


        String uri = "android.resource://" + getPackageName() + "/" + R.raw.mp002;  //本地
        //String uri2 = "https://flv2.bn.netease.com/videolib1/1811/26/OqJAZ893T/HD/OqJAZ893T-mobile.mp4";  //网络
        mVideoView.setVideoURI(Uri.parse(uri));  //本地
        //mVideoView.setVideoURI(Uri.parse(uri2));  //网络
        mMediaController.setMediaPlayer(mVideoView);
        mVideoView.setMediaController(mMediaController);
        mVideoView.start();
    }
}
